{include file="pageheader_erp.htm"}

<link href="styles/erp_order.css" rel="stylesheet" type="text/css" />

{insert_scripts files="../js/jquery.1.3.2.js"}
{insert_scripts files="../js/jquery.blockUI.2.23.js"}


<script language="javascript">
	

function order_specs(order_item)
{
	$.blockUI({ 
		  message: $('#order_specs_'+order_item), css: { 
		  top:  ($(window).height()-300) /2 + 'px', 
		  left: ($(window).width()-600) /2 + 'px'
		   }
	});	
}	
	
$(document).ready(function(){
	$("img[id^='img_submit_specs_']").click(function(){
		
		{if $order_info.available_act.edit eq 1}
			{if $act eq 'edit'}
				var order_id='{$order_info.order_id}';
				var order_item_id=$(this).attr('id');
				order_item_id=order_item_id.substr('img_submit_specs_'.length,order_item_id.length-'img_submit_specs_'.length);
				
				var specific_desc=$("#textarea_specific_desc_"+order_item_id).attr('value');;
	
				function changeSpecsResponse(res)
				{
					if(res.error!=0)
					{
						alert(res.message);
					}
					else{
						$.unblockUI();
					}
				}
				
				if(confirm('{$lang.erp_order_sure_to_change_specs}'))
				{
					Ajax.call('erp_order.php?act=change_specs', 'order_id='+order_id+'&order_item_id='+order_item_id +'&specific_desc='+specific_desc, changeSpecsResponse, 'POST', 'JSON');
				}
				else{
					$.unblockUI();
				}
					
			{else}
				$.unblockUI();
			{/if}	
		{else}
			$.unblockUI();
		{/if}
		
	});
	
	$("img[id^='img_close_specs_']").click(function(){
		$.unblockUI();
	});
	
});
</script>


{if $order_info.available_act.approve eq 1}
<script language="javascript">	
	
	function withdrawal_to_rate(order_id)
	{
		function withdrawalToRateResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location="./erp_order_manage.php?act=order_list";
			}
		}
		if(confirm('{$lang.erp_order_sure_to_withdrawal_to_rate}'))
		{	
			Ajax.call('erp_order.php?act=withdrawal_to_rate', 'order_id=' + order_id, withdrawalToRateResponse, 'POST', 'JSON');
		}			
	}	
	
	$(document).ready(function(){
		$("#img_close_approve_remark").click(function(){
			$.unblockUI();
		});
	});
	
	function approve_order(order_id,act)
	{
		function approveOrderResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				alert(res.message);
				window.document.location="./erp_order_manage.php?act=order_list";
			}
		}
		
		
		if(act=='pass')
		{
			$("#img_submit_approve").bind('click',function(){
			var approve_remark=$("#textarea_approve_remark").attr('value');
			if(confirm('{$lang.erp_order_sure_to_approve}'))
			{
				Ajax.call('erp_order.php?act=approve_pass', 'order_id='+order_id+'&approve_remark='+approve_remark, approveOrderResponse, 'POST', 'JSON');
			}
			else{
				$.unblockUI();
				$(this).unbind('click');			
			}					
			});

			$.blockUI({
		   	message: $('#approve_remark'), css: { 
		    top:  ($(window).height()-200) /2 + 'px', 
		    left: ($(window).width()-500) /2 + 'px'
		   }
		});	
		}
		else if(act=='reject')
		{
			$("#img_submit_approve").bind('click',function(){
			var approve_remark=$("#textarea_approve_remark").attr('value');
			if(confirm('{$lang.erp_order_sure_to_approve}'))
			{
				Ajax.call('erp_order.php?act=approve_reject', 'order_id='+order_id+'&approve_remark='+approve_remark, approveOrderResponse, 'POST', 'JSON');
			}
			else{
				$.unblockUI();
				$(this).unbind('click');			
			}					
			});
			$.blockUI({
		   	message: $('#approve_remark'), css: { 
		    top:  ($(window).height()-200) /2 + 'px', 
		    left: ($(window).width()-500) /2 + 'px'
		   }			
			});
		}
	}

</script>
{/if}


{if $order_info.available_act.rate eq 1}
<script language="javascript">	

	function withdrawal_to_edit(order_id)
	{
		function withdrawalToEditResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location="./erp_order_manage.php?act=order_list";
			}
		}
		if(confirm('{$lang.erp_order_sure_to_withdrawal_to_edit}'))
		{	
			Ajax.call('erp_order.php?act=withdrawal_to_edit', 'order_id=' + order_id, withdrawalToEditResponse, 'POST', 'JSON');
		}			
	}
	
	function post_to_approve(order_id)
	{
		var order_id='{$order_info.order_id}';	
		if(confirm('{$lang.erp_order_sure_to_post_to_approve}'))
		{
			Ajax.call('erp_order.php?act=post_to_approve', 'order_id='+order_id, postToApprove, 'POST', 'JSON');
		}
		function postToApprove(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				alert(res.message);
				window.document.location="./erp_order_manage.php?act=order_list";
			}
		}
	}
	
	function rate_all()
	{
		$("span[id^='span_price_']").hide();
		$("input[id^='input_price_']").show();
	}
	
	function rate_it(order_item_id)
	{
		$("#span_price_"+order_item_id).hide();
		$("#input_price_"+order_item_id).show();
	}
	
	$(document).ready(function(){
		$("span[id^='span_price_']").mouseover(function(){
			$(this).css('color','red');
		});
	
		$("span[id^='span_price_']").mouseout(function(){
			$(this).css('color','black');
		});	
	
		$("span[id^='span_price_']").css('cursor','pointer');
		
		$("span[id^='span_price_']").click(function(){
			var order_item_id=$(this).attr('id');
			order_item_id=order_item_id.substr('span_price_'.length,order_item_id.length-'span_price_'.length);		
			
			$(this).hide();
			$("#input_price_"+order_item_id).show().focus();
		});	
			
		$("input[id^='input_price_']").blur(function(){
			var order_item_id=$(this).attr('id');
			order_item_id=order_item_id.substr('input_price_'.length,order_item_id.length-'input_price_'.length);
			
			var order_id='{$order_info.order_id}';	
			var price=$(this).attr('value');
			
			if(isNaN(price))
			{
				alert('{$lang.erp_not_a_number}');
				}
			else{
				if(confirm('{$lang.erp_order_sure_to_change_price}'))
				{
					Ajax.call('erp_order.php?act=change_price', 'order_id='+order_id+'&order_item_id='+order_item_id+'&price='+price, changePriceResponse, 'POST', 'JSON');
				}
				else{
					$(this).hide();
					$(this).attr('value',$("#span_price_"+order_item_id).text());
					$("#span_price_"+order_item_id).show();
				}			
			}
			function changePriceResponse(res)
			{
				if(res.error!=0)
				{
					alert(res.message);
				}
				else{
					window.document.location="./erp_order_manage.php?act=rate_order&order_id="+order_id;		
				}
			}
			
		});
		
		
	});

</script>
{/if}
<script language="javascript">
	function execute_order(order_id)
	{
		var order_id='{$order_info.order_id}';	
		if(confirm('{$lang.erp_order_sure_to_execute}'))
		{
			Ajax.call('erp_order.php?act=execute_order', 'order_id='+order_id, postToExecute, 'POST', 'JSON');
		}
		function postToExecute(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location="./erp_order_manage.php?act=order_list";
			}
		}
	}
	function finish_order(order_id)
	{
		var order_id='{$order_info.order_id}';	
		if(confirm('{$lang.erp_order_sure_to_finish}'))
		{
			Ajax.call('erp_order.php?act=finish_order', 'order_id='+order_id, postToExecute, 'POST', 'JSON');
		}
		function postToExecute(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location="./erp_order_manage.php?act=order_list";
			}
		}
	}
</script>
{if $order_info.available_act.edit eq 1}
{if $act eq 'edit'}
<script language="javascript">	
/*
 * 修改订单信息
 */	
$(document).ready(function(){
   		
			//订单描述
			$("#span_order_description").mouseover(function(){
				$(this).css('color','red');
			});
			
			$("#span_order_description").mouseout(function(){
				$(this).css('color','black');
			});

			$("#span_order_description").css('cursor','pointer');
		
			$("#span_order_description").click(function(){
				$(this).hide();
				$("#input_order_description").show();
				$("#input_order_description").focus();
			});
			
			var old_description=$("#span_order_description").text();
			
			$("#input_order_description").change(function(){
				var order_id='{$order_info.order_id}';
				var new_description=$(this).attr('value');
				
				function changeDescriptionResponse(res)
				{
					if(res.error!=0)
					{	
						alert(res.message);
						}
					else
					{
						window.document.location="./erp_order_manage.php?act=edit_order&order_id="+order_id;	
					}
				}
				if(confirm('{$lang.erp_order_sure_to_change_order_description}'))
				{
					Ajax.call('erp_order.php?act=change_description', 'order_id=' + order_id+'&new_description='+new_description, changeDescriptionResponse, 'POST', 'JSON');
				}
				else{
						$("#input_order_description").hide();
						$("#span_order_description").show();	
						$("#input_order_description").attr('value',$("#span_order_description").text());				
				}
			});
			$("#input_order_description").blur(function(){
					$("#input_order_description").hide();
					$("#span_order_description").show();					
			});
			
			//更改供应商
			$("#span_supplier_name").mouseover(function(){
				$(this).css('color','red');
			});
			
			$("#span_supplier_name").mouseout(function(){
				$(this).css('color','black');
			});

			$("#span_supplier_name").css('cursor','pointer');
		
			$("#span_supplier_name").click(function(){
				$(this).hide();
				$("#select_supplier").show();
			});			
			
			var old_supplier_code=$("#input_supplier").attr('value');
			
			$("#input_supplier").change(function(){
				var supplier_code=$(this).attr('value');
				var order_id='{$order_info.order_id}';
				
				function changesupplierResponse(res)
				{
					if(res.error==0)
					{
						window.document.location="./erp_order_manage.php?act=edit_order&order_id="+order_id;				
					}
					else
					{
						alert(res.message);
					}										
				}
				if(confirm('{$lang.erp_order_sure_to_change_order_supplier}'))
				{
					Ajax.call('erp_order.php?act=change_supplier', 'order_id=' + order_id+'&supplier_code='+supplier_code, changesupplierResponse, 'POST', 'JSON');
				}
				else{
						$("#input_supplier").hide();
						$("#select_supplier").hide();	
						$("#span_supplier_name").show();
						$("#input_supplier").attr('value',old_supplier_code);					
				}
			});
			$("#input_supplier").blur(function(){
				$("#select_supplier").hide();
				$(this).hide();
				$("#span_supplier_name").show();
			});
			
			$("#select_supplier").change(function(){
				var supplier_code=$(this).attr('value');
				var order_id='{$order_info.order_id}';
				
				function changeSupplierResponse(res)
				{
					if(res.error==0)
					{
						window.document.location="./erp_order_manage.php?act=edit_order&order_id="+order_id;				
					}
					else
					{
						alert(res.message);
					}				
				}
				if(supplier_code!='')
				{
					if(confirm('{$lang.erp_order_sure_to_change_order_supplier}'))
					{
						Ajax.call('erp_order.php?act=change_supplier', 'order_id=' + order_id+'&supplier_code='+supplier_code, changeSupplierResponse, 'POST', 'JSON');
					}
					else{
						$("#input_supplier").hide();
						$("#select_supplier").hide();	
						$("#span_supplier_name").show();						
					}					
				}				
			});
			
			//添加订单项
			$("#btn_add_order_item").css('cursor','pointer');	
			
			$("#btn_add_order_item").click(function(){
				order_id='{$order_info.order_id}';
				function addOrderItemResponse(res)
				{
					if(res.error!=0)
					{
						alert(res.message);
					}
					else{
						window.document.location="./erp_order_manage.php?act=edit_order&order_id="+order_id;
					}
				}
				
				Ajax.call('erp_order.php?act=add_order_item', 'order_id=' + order_id, addOrderItemResponse, 'POST', 'JSON');
			});
			
			//修改产品货号
			$("span[id^='span_goods_sn_']").css('cursor','pointer');	
			$("span[id^='span_goods_sn_']").mouseover(function(){
				$(this).css('color','red');
			});
			$("span[id^='span_goods_sn_']").mouseout(function(){
				$(this).css('color','black');
			});			
			$("span[id^='span_goods_sn_']").click(function(){
				var order_item_id=$(this).attr('id');
				order_item_id=order_item_id.substr('span_goods_sn_'.length,order_item_id.length-'span_goods_sn_'.length);
				
				$("#input_goods_sn_"+order_item_id).show().focus();
				$(this).hide();  
			});
			
			$("input[id^='input_goods_sn_']").blur(function(){
				var order_item_id=$(this).attr('id');
				order_item_id=order_item_id.substr('input_goods_sn_'.length,order_item_id.length-'input_goods_sn_'.length);
				
				var order_id='{$order_info.order_id}';
				var goods_sn=$(this).attr('value');
				
				function changeGoodsSNResponse(res)
				{
					if(res.error!=0)
					{
						alert(res.message);	
					}
					else{	
						window.document.location="./erp_order_manage.php?act=edit_order&order_id="+order_id;	
						
					}
				}
				if(confirm('{$lang.erp_order_sure_to_change_goods_sn}'))
				{
					Ajax.call('erp_order.php?act=change_goods_sn', "order_id="+order_id+'&order_item_id=' + order_item_id+'&goods_sn='+goods_sn, changeGoodsSNResponse, 'POST', 'JSON');
				}
				else{
					$("#span_goods_sn_"+order_item_id).show();
					$("#input_goods_sn_"+order_item_id).hide();
					//$("#input_goods_sn_"+order_item_id).attr('value',$("#span_goods_sn_"+order_item_id).html());					
				}				
			});
			
		
			//修改产品数量
			$("span[id^='span_order_qty_']").css('cursor','pointer');	
			$("span[id^='span_order_qty_']").mouseover(function(){
				$(this).css('color','red');
			});
			$("span[id^='span_order_qty_']").mouseout(function(){
				$(this).css('color','black');
			});			
			$("span[id^='span_order_qty_']").click(function(){
				var order_item_id=$(this).attr('id');
				order_item_id=order_item_id.substr('span_order_qty_'.length,order_item_id.length-'span_order_qty_'.length);
				
				$("#input_order_qty_"+order_item_id).show().focus();
				$(this).hide();  
			});	
			
			$("input[id^='input_order_qty_']").blur(function(){
				var order_item_id=$(this).attr('id');
				order_item_id=order_item_id.substr('input_order_qty_'.length,order_item_id.length-'input_order_qty_'.length);			
				
				var order_qty=$(this).attr('value');
				var order_id='{$order_info.order_id}';
				
				var $span_order_qty=$('#span_order_qty_'+order_item_id);
				var $input_order_qty=$('#input_order_qty_'+order_item_id);
				
				if(isNaN(order_qty))
				{
					alert('{$lang.erp_not_a_number}');
				}
				else{
					
					function changeOrderQtyResponse(res)
					{
						if(res.error!=0)
						{
							alert(res.message);
						}
						else{
							
							window.document.location="./erp_order_manage.php?act=edit_order&order_id="+order_id;	
							
						}
					}
					
					order_qty=parseInt(order_qty);
					
					if(confirm('{$lang.erp_order_sure_to_change_order_qty}'))
					{
						Ajax.call('erp_order.php?act=change_order_qty', "order_id="+order_id+'&order_item_id='+order_item_id+'&order_qty='+order_qty, changeOrderQtyResponse, 'POST', 'JSON');
					}
					else{
						$span_order_qty.show();
						$input_order_qty.hide();
						$input_order_qty.attr('value',$span_order_qty.text());
					}						
				}
			});						
			
	
   });   

/*
 * 删除订单
 */	  
function delete_order(order_id)
{
		function deleteOrderResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location='erp_order_manage.php?act=order_list';
			}
		}
				
		if(confirm('{$lang.erp_order_sure_to_delete_order}'))
		{
			Ajax.call('erp_order.php?act=delete_order', 'order_id=' + order_id, deleteOrderResponse, 'POST', 'JSON');
		}
}
			
function edit_order(order_id)
{
	//$("#input_supplier").show();
	$("#select_supplier").show();	
	$("#span_supplier_name").hide();
				
	$("#input_order_description").show();
	$("#span_order_description").hide();	
}
			
function post_to_rate(order_id)
{
	function postToRateResponse(res)
	{
		if(res.error!=0)
		{
			alert(res.message);
		}
		else{
			alert(res.message);
			window.document.location="./erp_order_manage.php?act=order_list";
		}
	}
	if(confirm('{$lang.erp_order_sure_to_post_order}'))
	{	
		Ajax.call('erp_order.php?act=post_to_rate', 'order_id=' + order_id, postToRateResponse, 'POST', 'JSON');
		}
}
			
function edit_order_item(order_item_id)
{
	var $span_goods_sn=$('#span_goods_sn_'+order_item_id);
	var $input_goods_sn=$('#input_goods_sn_'+order_item_id);
	var $span_goods_attr=$('#span_goods_attr_'+order_item_id);
	var $input_goods_attr=$('#input_goods_attr_'+order_item_id);
	var $span_order_qty=$('#span_order_qty_'+order_item_id);
	var $input_order_qty=$('#input_order_qty_'+order_item_id);
				
	$span_goods_sn.hide();
	$input_goods_sn.show();
	$span_goods_attr.hide();
	$input_goods_attr.show();
	$span_order_qty.hide();
	$input_order_qty.show();
	}
			
function delete_order_item(order_item_id)
{
	var order_id='{$order_info.order_id}';
				
	function deleteOrderItemResponse(res)
	{
		if(res.error!=0)
		{
			alert(res.message);
		}
		else{
			window.document.location="./erp_order_manage.php?act=edit_order&order_id="+order_id;	
		}
	}
	if(confirm('{$lang.erp_order_sure_to_delete_order_item}'))
	{
		Ajax.call('erp_order.php?act=delete_order_item', 'order_id=' + order_id + '&order_item_id=' + order_item_id, deleteOrderItemResponse, 'POST', 'JSON');
	}
				
}


</script>
{/if}
{/if}

{if $act neq 'view'}
{if $order_info.available_act.edit eq 1}
 
<div class="goods_attr" id="goods_attr">
<div class="goods_attr_head">
	<table cellpadding="0" cellspacing="0" border='0'>
		<tr>
			<td>
				<img src="./images/goods_attr.gif" />
			</td>
			<td align="right">
				<span><img style="cursor:pointer;" id="img_close_goods_attr" src="./images/close_erp.gif" /></span>
			</td>
		</tr>
	</table>
</div>

<div class="goods_attr_box" id="goods_attr_box">

</div>
<div class="div_submit_goods_attr">
	<img style="cursor:pointer;" id="img_submit_goods_attr" src="./images/submit.gif" />
</div>	
</div>
 
<script type="text/javascript">
	
	var attr_num=0;
	var orderItemId=0;
	
	function change_attr(order_item_id)
	{
		attr_num=0;
		
		orderItemId=order_item_id;
		
		var order_id='{$order_info.order_id}';
		
		Ajax.call('erp_order.php?act=get_goods_attr', 'order_id=' + order_id + '&order_item_id=' + order_item_id, getAttrResponse, 'POST', 'JSON');
		
		function getAttrResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message)
			}
			else{
				$("#tb_goods_attr").empty();
				$("#goods_attr_box").html(res.attr_info);
				attr_num=res.attr_num;
				
				//显示属性选择
				$.blockUI({
		   			message: $('#goods_attr'), css: { 
		   	 		top:  ($(window).height()-200) /2 + 'px', 
		    		left: ($(window).width()-500) /2 + 'px'
		   		}
				});
				}
		}
	}
	
	$(document).ready(function(){
		
		$("#img_close_goods_attr").click(function(){
			$.unblockUI();
		});
		
		$("#img_submit_goods_attr").attr('style','cursor:pointer');
		
		$("#img_submit_goods_attr").click(function(){
				
				var order_id='{$order_info.order_id}';
				var ids='';
				var selected_attr_num=0;
				
				$("input[id^='goods_attr_']").each(function(i){
						
						var is_checked=$($("input[id^='goods_attr_']")[i]).attr('checked');
			
						if(is_checked==true)
						{
							var id=$($("input[id^='goods_attr_']")[i]).attr('id');
							id=id.substr('goods_attr_'.length,id.length-'goods_attr_'.length);	
							
							selected_attr_num=selected_attr_num+1;	
							
							if(selected_attr_num<attr_num)	
							{
								ids=ids+id+',';	
							}
							else{
								ids=ids+id;	
							}	
						}
				});	
				
				if(selected_attr_num<attr_num)
				{
					alert('{$lang.erp_order_attr_not_select}');
				}
				else{

					function setAttrResponse(res)
					{
						if(res.error!=0)
						{
							alert(res.message);
						}
						else{
							window.document.location="./erp_order_manage.php?act=edit_order&order_id="+order_id;	
						}
					}
					
					Ajax.call('erp_order.php?act=set_goods_attr', 'order_id=' + order_id + '&order_item_id=' + orderItemId + '&ids=' + ids, setAttrResponse, 'POST', 'JSON');
					
				}				
		});
		
	});
	
</script>
 
{/if}
{/if}

<!-- start approve remark -->
{if $order_info.available_act.approve eq 1}
 
<div class="approve_remark" id="approve_remark">
<div class="approve_remark_head">
	<table cellpadding="0" cellspacing="0" border='0'>
		<tr>
			<td>
				<img src="./images/approve_remark.gif" />
			</td>
			<td align="right">
				<span><img id="img_close_approve_remark" src="./images/close_erp.gif" style="cursor:pointer;" /></span>
			</td>
		</tr>
	</table>
</div>

<div class="approve_remark_box">
<table  cellpadding="5" cellspacing="0" border='0'>
	 <tr>
    	<td width="60">{$lang.erp_approve_remark}</td>	
		<td>
			<textarea rows="8" cols="55" id="textarea_approve_remark">{$order_info.approve_remark}</textarea>
		</td>
	</tr>	
</table>
</div>
<div class="div_submit_approve">
	<img id="img_submit_approve" src="./images/submit.gif" style="cursor:pointer;" />
</div>	
</div>
 
{/if}
<!-- end approve remark -->



 <!-- start order info -->
<div class="list-div" id="listDiv">
<table  cellpadding="3" cellspacing="1">
  <tr>
    <th width="8%">{$lang.erp_order_sn}</th>
 	<th>{$lang.erp_order_description}</th>
	<th width="20%">{$lang.erp_order_supplier}</th>
	<th width="10%">{$lang.erp_order_date}</th>
	<th width="10%">{$lang.erp_order_status}</th>
	{if $act neq 'view'}<th width="15%">{$lang.erp_operation}</th>{/if}
  <tr>
  <tr>
	<td align="center">{$order_info.order_sn}</td>	
	<td>
		<span id="span_order_description">{if $order_info.description}{$order_info.description}{else}{$lang.erp_NULL}{/if}</span>
		<input id="input_order_description" style="display:none;" value="{$order_info.description}"/>
	</td>	
	<td id="order_supplier">
		<span {if $supplier_info} id="span_supplier_name"{/if}>{if $order_info.supplier_name}{$order_info.supplier_name}{else}{$lang.erp_NULL}{/if}</span>
		{if $order_info.available_act.edit eq 1}
			{if $supplier_info}
			<input style="display:none;" id="input_supplier" size="5" maxlength="5" value="{$order_info.supplier_code}" />
			
			<select  style="display:none;" id="select_supplier" style="width:150px;">
			<option value="">{$lang.erp_order_select_supplier}</option>
			{foreach from=$supplier_info item=supplier}
					<option value="{$supplier.code}" {if $order_info.supplier_code eq $supplier.code}selected="selected"{/if}>{$supplier.name}</option>
			{/foreach}
			</select>
			{/if}
		{/if}
	</td>
	<td align="center">{$order_info.create_date}</td>
	<td align="center">
		{if $order_info.order_status eq 1}{$lang.erp_order_status_inputing}{/if}
		{if $order_info.order_status eq 2}{$lang.erp_order_status_rating}{/if}
		{if $order_info.order_status eq 3}{$lang.erp_order_status_approving}{/if}
		{if $order_info.order_status eq 4}{$lang.erp_order_status_approve_pass}{/if}
		{if $order_info.order_status eq 5}{$lang.erp_order_status_approve_reject}{/if}
		{if $order_info.order_status eq 6}{$lang.erp_order_status_execute}{/if}
		{if $order_info.order_status eq 7}{$lang.erp_order_status_finish}{/if}
	</td>
	{if $act neq 'view'}	
	<td align="center"  >
		{if $order_info.available_act.edit eq 1}<a href="javascript:edit_order({$order_info.order_id})">{$lang.erp_operation_edit}</a>{/if}
		{if $order_info.available_act.delete eq 1}<a href="javascript:delete_order({$order_info.order_id})">{$lang.erp_operation_delete}</a>{/if}
		{if $order_info.available_act.post_to_rate eq 1}<a href="javascript:post_to_rate({$order_info.order_id})">{$lang.erp_operation_post_to_finance}</a>{/if}
		{if $order_info.available_act.rate eq 1}
			<a href="javascript:rate_all({$order_info.order_id})">{$lang.erp_operation_rate}</a>
			<a href="javascript:withdrawal_to_edit({$order_info.order_id})">{$lang.erp_operation_withdrawal}</a>
		{/if}
		{if $order_info.available_act.post_to_approve eq 1}<a href="javascript:post_to_approve({$order_info.order_id})">{$lang.erp_operation_post_to_approve}</a>{/if}
		{if $order_info.available_act.approve eq 1}
			<a href="javascript:approve_order({$order_info.order_id},'pass')">{$lang.erp_operation_approve_pass}</a>
			<a href="javascript:approve_order({$order_info.order_id},'reject')">{$lang.erp_operation_approve_reject}</a>
			<a href="javascript:withdrawal_to_rate({$order_info.order_id})">{$lang.erp_operation_withdrawal}</a>
		{/if}
		{if $order_info.available_act.execute eq 1}
			<a href="javascript:execute_order({$order_info.order_id})">{$lang.erp_operation_execute}</a>
		{/if}
		{if $order_info.available_act.finish eq 1}
			<a href="javascript:finish_order({$order_info.order_id})">{$lang.erp_operation_finish}</a>
		{/if}
    </td>
	{/if}				
  </tr>
</table>
</div>
<!-- end order info -->

<br />


<!-- start order item info -->
{if $order_info.available_act.edit eq 1}
{if $act eq 'edit'}
	<div style="width:100%;text-align:right;margin-bottom:5px;"><img id="btn_add_order_item" src="./images/add_order_item.gif" /></div>
{/if}
{/if}



<style type=text/css>
	.zoom_container
	{
		height:300px;
		width:311px;
		overflow:hidden;
		position:absolute;
		z-index:100;
		display:none;
	}
	.zoom_pointer
	{
		height:300px;
		width:11px;
		margin:0px;
		overflow:hidden;
		float:left;
		position:relative;
	}
	.zoom_img
	{
		height:298px;
		width:299px;
		margin:0px;
		background-color:#FFF;
		border-top:1px solid #BBDDE5;
		border-right:1px solid #BBDDE5;
		border-bottom:1px solid #BBDDE5;
		overflow:hidden;
		float:left;
		position:relative;
	}	
	
</style>

<script language="JavaScript">
   $(document).ready(function(){

	$("img[id^='goods_img_']").mouseover(function(){
			var order_item_id=$(this).attr('id');
			order_item_id=order_item_id.substr('goods_img_'.length,order_item_id.length-'goods_img_'.length);
			
			this_width=$(this).css('width');
			this_width=this_width.substr(0,this_width.length-2);
			this_width=parseInt(this_width);
			
			var position_x=$(this).offset().left;
			var position_y=$(this).offset().top;

			$("#zoom_goods_img_"+order_item_id).css('top',position_y-30);
			$("#zoom_goods_img_"+order_item_id).css('left',position_x+this_width);
			
			$("#zoom_goods_img_"+order_item_id).show();
		});
	$("img[id^='goods_img_']").mouseout(function(e){
		var order_item_id=$(this).attr('id');
		order_item_id=order_item_id.substr('goods_img_'.length,order_item_id.length-'goods_img_'.length);
		
		$("#zoom_goods_img_"+order_item_id).hide();
	});	
   });
 
</script>

<div id="zoom_div">
{foreach from=$order_item_info item=order_item}	

	{if $order_item.goods_details}
	<div class="zoom_container" id="zoom_goods_img_{$order_item.order_item_id}">
			<div class="zoom_pointer">
				<img src="./images/line_left.gif">
			</div>
			<div class="zoom_img">
				<img width="297" weight="297" src="{$order_item.goods_details.goods_img}">
			</div>
	</div>	
	{/if}

	<div class="zoom_container" id="zoom_goods_draft_{$order_item.order_item_id}">
			<div class="zoom_pointer">
				<img src="./images/line_left.gif">
			</div>
			<div class="zoom_img">
				<img width="297" weight="297" src="{$order_item.draft_info.img_url}">
			</div>
	</div>	

	{foreach from=$order_item.stuff_info key=key item=stuff}
		{if $stuff}	
		<div class="zoom_container" id="zoom_goods_stuff_{$key}_{$order_item.order_item_id}">
			<div class="zoom_pointer">
				<img src="./images/line_left.gif">
			</div>
			<div class="zoom_img">
				<img width="297" weight="297" src="{$stuff.img_url}">
			</div>
		</div>			
		{/if}				
	{/foreach}	
	
{/foreach}
</div>

<div class="list-div" id="listDiv">
<table  cellpadding="3" cellspacing="1">
  <tr>
    <th width="5%">{$lang.erp_order_item_id}</th>
	<th width="8%">{$lang.erp_order_item_goods_img}</th>
    <th width="8%">{$lang.erp_order_item_goods_sn}</th>
	<th>{$lang.erp_order_item_goods_name}</th>
	<th width="8%">{$lang.erp_order_item_goods_attr}</th>
	<th width="8%">{$lang.erp_order_item_order_qty}</th>
	<th width="8%">{$lang.erp_order_item_order_price}</th>
	<th width="8%">{$lang.erp_order_item_order_amount}</th>
	<th width="12%">{$lang.erp_operation}</th>
  </tr>
	{foreach from=$order_item_info key=key item=order_item}	
		<tr id="tr_order_item_{$order_item.order_item_id}">
		<td align="center">{$order_item.order_item_id}</td>
		<td align="center">
			<img  {if $order_item.goods_details.goods_thumb}id="goods_img_{$order_item.order_item_id}"{/if} width="100" height="100" src="{if $order_item.goods_details.goods_thumb}{$order_item.goods_details.goods_thumb}{else}./images/no_img.gif{/if}">
		</td>
		<td>
			<span id="span_goods_sn_{$order_item.order_item_id}">
				{if $order_item.goods_details}
					{$order_item.goods_details.goods_sn}
				{else}	
					{$lang.erp_order_input_goods_sn}
				{/if}	
			</span>
			<input id="input_goods_sn_{$order_item.order_item_id}" size="10" maxlength="10" value="{$order_item.goods_details.goods_sn}" style="display:none;">		
		</td>
		<td>
			<span id="span_goods_name_{$order_item.order_item_id}">{$order_item.goods_details.goods_name}</span>
		</td>
		
		<td align="center">
			{if $order_item.selected_attr}
			<table>
				{foreach from=$order_item.selected_attr item=attr}
					<tr>
						<td>{$attr.attr_name}：</td>
						<td>{$attr.attr_value}</td>
					</tr>
				{/foreach}
			</table>
			{else}
				{$lang.erp_NULL}	
			{/if}		
		</td>		
		<td align="center">
			<span {if $order_item.goods_id neq 0}id="span_order_qty_{$order_item.order_item_id}"{/if}>{$order_item.order_qty}</span>
			<input size="5" style="display:none;" id="input_order_qty_{$order_item.order_item_id}" value="{$order_item.order_qty}">		
		</td>
		<td align="center">
			<span id="span_price_{$order_item.order_item_id}">{$order_item.price}</span>	
			<input size="5" style="display:none;" id="input_price_{$order_item.order_item_id}" value="{$order_item.price}">	
		</td>
		<td align="center">
			<span id="amount_{$order_item.order_item_id}">{$order_item.amount}</span>
		</td>
		<td align="center">
			{if $act neq 'view'}
				{if $order_info.available_act.edit eq 1}<a href="javascript:change_attr({$order_item.order_item_id})">{$lang.erp_operation_change_attr}</a>{/if}
			{/if}
			<a href="javascript:order_specs({$order_item.order_item_id})">{$lang.erp_order_operation_view_details}</a>
			{if $act neq 'view'}
				{if $order_info.available_act.delete eq 1}<a href="javascript:delete_order_item({$order_item.order_item_id})">{$lang.erp_operation_delete}</a>{/if}	
			{/if}
		</td>
	</tr>	
	{foreachelse}
  		<tr><td class="no-records" colspan="12">{$lang.no_records}</td></tr>
  {/foreach}
</table>

<div class="order_sum_total">
	{$lang.erp_order_sum_total}
	<span id="span_total_order_qty">{if $order_info.order_qty}{$order_info.order_qty}{else}0{/if}</span>
	{$lang.erp_order_qty_unit}，
	<span id="span_total_order_amount">{if $order_info.order_amount}{$order_info.order_amount}{else}0{/if}</span>
	{$lang.erp_order_amount_unit}
</div>

</div>
<!-- end order item info -->


<!-- start order specs info -->
{foreach from=$order_item_info item=order_item}	
<div class="order_specs" id="order_specs_{$order_item.order_item_id}">
	<div class="order_specs_head">
	<table cellpadding="0" cellspacing="0" border='0'>
		<tr>
			<td>
				<img src="./images/order_specs.gif" />
			</td>
			<td align="right">
				<span><img style="cursor:pointer;" id="img_close_specs_{$order_item.order_item_id}" src="./images/close_erp.gif" /></span>
			</td>
		</tr>
	</table>
	</div>

	<div class="order_specs_box">
		<table cellpadding="5" cellspacing="0" border='0'>
		
			<tr>
				<td width="20%">
					{$lang.erp_order_specific}
				</td>
				<td>
					<textarea {if $order_info.available_act.edit eq 1}{if $act eq 'view'}disabled="disabled"{/if}{else}disabled="disabled"{/if} cols="62" rows="8" id="textarea_specific_desc_{$order_item.order_item_id}">{$order_item.specific_desc}</textarea>
				</td>
			</tr>
					
		</table>
	</div>
	<div class="div_submit_specs"><img style="cursor:pointer;" id="img_submit_specs_{$order_item.order_item_id}" src="./images/submit.gif" /></div>	
</div>	
{/foreach}
<!-- end order specs info -->



{include file="pagefooter.htm"}

